package com.huahua.graduateschoolspringboot.entity.vo;

import cn.hutool.core.util.NumberUtil;
import cn.hutool.core.util.StrUtil;
import com.google.common.collect.Lists;
import com.huahua.graduateschoolspringboot.entity.po.CityLightConfig;
import lombok.Data;

import javax.print.attribute.standard.NumberUp;
import java.time.format.DateTimeFormatter;
import java.util.List;
import java.util.stream.Collectors;

/**
 * @author LoveHuaHua
 * @date 2023年05月08日 7:55
 * @description believe in yourself
 */
@Data
public class CityLightConfigVo extends CityLightConfig {

    /**
     * 时间
     */
    private String time;

    private List<String> deviceListArr = Lists.newArrayList();

    public List<String> getDeviceListArr() {
        List<String> split = StrUtil.split(getDeviceList(), ",");
        return split.stream().map(NumberUtil::parseInt).map(String::valueOf).collect(Collectors.toList());
    }

    public String getTime() {
        return getStartTime().format(DateTimeFormatter.ofPattern("HH:mm:ss")) + "-" + getEndTime().format(DateTimeFormatter.ofPattern("HH:mm:ss"));
    }
}
